

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

//带有RGBA的颜色设置
#define RGB(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0f]
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]

//高度定义
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define WIDTH  self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

#define STATUS_BAR_HEIGHT ([UIApplication sharedApplication].statusBarFrame.size.height)
#define NAV_HEIGHT (STATUS_BAR_HEIGHT+44)

#define NAVBAR_TINCOLOR_WHITE \
        [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];\
        [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];\
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

#define NAVBAR_TINCOLOR_BLACK \
        [self.navigationController.navigationBar setTintColor:RGB(51,51,51)];\
        [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:RGB(51,51,51)}];\
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;

#define APP_NAME [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]

//NSUserDefaults 实例化
#define USER_DEFAULT [NSUserDefaults standardUserDefaults]

//读取本地图片
#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]

#pragma mark - 系统
#define IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

#define dispatch_async_main_safe(block)\
if ([NSThread isMainThread]) {\
block();\
} else {\
dispatch_async(dispatch_get_main_queue(), block);\
}

#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
#define SYS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#ifdef DEBUG
#   define DLog(fmt, ...) {NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);}
#   define ELog(err) {if(err) DLog(@"%@", err)}
#else
#   define DLog(...)
#   define ELog(err)
#endif

//判断iphoneX系列
static inline BOOL isIPhoneXSeries() {
    BOOL iPhoneXSeries = NO;
    if (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPhone) {
        return iPhoneXSeries;
    }
    if (@available(iOS 11.0, *)) {
        UIWindow *mainWindow = [[[UIApplication sharedApplication] delegate] window];
        if (mainWindow.safeAreaInsets.bottom > 0.0) {
            iPhoneXSeries = YES;
        }
    }
    return iPhoneXSeries;
}

//底部安全区域高度
static inline CGFloat SafeArea_Height() {
    CGFloat height = isIPhoneXSeries() ? 34 : 0;
    return height;
}

//16进制颜色
static inline UIColor *CHNHexColor(uint32_t rgbValue, CGFloat alpha) {
    return [UIColor colorWithRed:((CGFloat)((rgbValue & 0xFF0000) >> 16)) / 255.0
                           green:((CGFloat)((rgbValue & 0xFF00) >> 8)) / 255.0
                            blue:((CGFloat)(rgbValue & 0xFF)) / 255.0
                           alpha:(alpha)];
}

//标准灰色背景
static inline UIColor *Gray_BackgroundColor() {
    return CHNHexColor(0xbfbfbf,1);
}

//标准标题颜色
static inline UIColor *Title_Color() {
    return CHNHexColor(0x333333,1);
}

//标准注释颜色(容易被忽略的颜色 不太起眼的颜色)
static inline UIColor *Comment_Color() {
    return CHNHexColor(0x999999,1);
}

//标准分割线颜色
static inline UIColor *kNewSepector_Color() {
    return  CHNHexColor(0xdddddd,1);
}

//依据宽度大小自适应
static inline CGFloat SmtSize(CGFloat size){
    float iphone6width=375.0;
    float scale=([UIScreen mainScreen].bounds.size.width)/iphone6width;
    return scale*size;
}

//*********标准字体大小***********
static inline UIFont* SystemFont(CGFloat size){
    return [UIFont systemFontOfSize:size];
}
static inline UIFont* BoldFont(CGFloat size){
    return [UIFont boldSystemFontOfSize:size];
}
static inline UIFont* CustomFont(CGFloat size,UIFontWeight weight){
    return [UIFont systemFontOfSize:size weight:weight];
}

//自适应字体
static inline UIFont* SmtSystemFont(CGFloat size){
    return [UIFont systemFontOfSize:SmtSize(size)];
}
static inline UIFont* SmtBoldFont(CGFloat size){
    return [UIFont boldSystemFontOfSize:SmtSize(size)];
}
static inline UIFont* SmtCustomFont(CGFloat size,UIFontWeight weight){
    return [UIFont systemFontOfSize:SmtSize(size) weight:weight];
}


/**
 *  通用事件回调
 *  @param data  data 回传数据
 *  @param view  view 处发事件iew
 *  @param index index 处发事件索引或列表索引
 */
typedef void (^ViewsEventBlock)(id _Nullable data,UIView *_Nullable view,NSInteger index);


